using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vPoReceiptsHeaderMap : EntityTypeConfiguration<vPoReceiptsHeader>
    {
        public vPoReceiptsHeaderMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Receipt_Number, t.DATE, t.POSTED, t.Currency_Id, t.Currency_Symbol });

            // Properties
            this.Property(t => t.Receipt_Number)
                .IsRequired()
                .HasMaxLength(7);

            this.Property(t => t.Order_Number)
                .HasMaxLength(8);

            this.Property(t => t.InVoice_Number)
                .HasMaxLength(8);

            this.Property(t => t.Currency_Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Currency)
                .HasMaxLength(20);

            this.Property(t => t.Currency_Symbol)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.ShipNum)
                .HasMaxLength(20);

            this.Property(t => t.InvoiceInSipment)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("vPoReceiptsHeaders");
            this.Property(t => t.Receipt_Number).HasColumnName("Receipt Number");
            this.Property(t => t.Order_Number).HasColumnName("Order Number");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.COST).HasColumnName("COST");
            this.Property(t => t.External_Overheads___).HasColumnName("External Overheads($)");
            this.Property(t => t.Local_Overheads___).HasColumnName("Local Overheads($)");
            this.Property(t => t.FOBCOST_).HasColumnName("FOBCOST$");
            this.Property(t => t.LandedCOST_).HasColumnName("LandedCOST$");
            this.Property(t => t.POSTED).HasColumnName("POSTED");
            this.Property(t => t.InVoice_Number).HasColumnName("InVoice Number");
            this.Property(t => t.TotalQty).HasColumnName("TotalQty");
            this.Property(t => t.Currency_Id).HasColumnName("Currency Id");
            this.Property(t => t.Currency).HasColumnName("Currency");
            this.Property(t => t.Currency_Symbol).HasColumnName("Currency Symbol");
            this.Property(t => t.ShipNum).HasColumnName("ShipNum");
            this.Property(t => t.InvoiceInSipment).HasColumnName("InvoiceInSipment");
            this.Property(t => t.priceamountLL).HasColumnName("priceamountLL");
            this.Property(t => t.priceamount_).HasColumnName("priceamount$");
        }
    }
}
